package com.example.tbplus14.Test;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

public class SingletonClass {

    private SingletonClass(){}

    private enum Singleton{
        INSTANCE;
        private final SingletonClass singletonClass = new SingletonClass();
    }

    public static SingletonClass getInstance(){
        return Singleton.INSTANCE.singletonClass;
    }

    private static class Instance{
        private final static SingletonClass SINGLETON_CLASS = new SingletonClass();
    }

    public static SingletonClass getInstance2(){
        return Instance.SINGLETON_CLASS;
    }

    public static void main(String[] args) {

        for (int i = 0; i < 10; i++) {
            System.out.println(SingletonClass.getInstance());

        }
        System.out.println();
        System.out.println("-----------------------------------");
        System.out.println();
        for (int i = 0; i < 10; i++) {
            System.out.println(SingletonClass.getInstance2());

        }
        System.out.println(JSONObject.toJSONString(null));

    }

}
